/**
 * Copyright 2015-2016 eyaomall.cn
 * All rights reserved.
 *
 * @project
 * @author pro
 * @version 1.0
 * @date 2016-03-07
 */
package com.eyaomall.wxmanage.interceptor;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.eyaomall.wxmanage.common.helper.MemberHelper;
import com.lycheeframework.core.common.helper.GlobEnv;

/**
 * 登录拦截器
 * @author pro
 *
 */
public class LoginInterceptor extends HandlerInterceptorAdapter {

	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
		Integer memberId = MemberHelper.getId();
		if(memberId == null || memberId <= 0){
			response.sendRedirect(GlobEnv.getWebURL("login"));
			return false;
		}
		MemberHelper.writeLastTime();
		return true;
	}
	
}
